frondoc picture
What is Frontier?
Download
News & Updates
Mailing Lists
Sample Scripts
Site Outline
Search
Guestbook
BBS
User's Guide
1 2 3 4 5 6
7 8 9 10 11
Apple File Edit
Main Open Suites
Web Window
Menubar Outline
Script Table WP

Frontier website on www.scripting.com

Website Scripting with BBEdit

With Frontier running in the background, BBEdit becomes more powerful, and building complex websites gets easier.

Here's what you get...

Requirements, Downloading

This package requires BBEdit 3.5.2 or greater. It will not work with BBEdit Lite.

You will need Frontier 4.0.1 or greater. Visit the Frontier 4.2 Download Page for the most recent version of Frontier.

You'll also need a compatible web browser to preview your pages, and Fetch 3.0 or greater to upload the resulting text to your server. Two browsers are compatible, Netscape 2.0 or greater and Microsoft Internet Explorer 2.0 or greater. In this text, anywhere it says "compatible browser" we mean either of these two applications.

While you're downloading, you might want to know that...

Frontier remains free

Frontier remains free and the new scripts are free. We want more people to use Frontier for website building. The goal is to grow the market, to make the Macintosh platform really excel at building powerful websites.

Both BBEdit and Frontier are important parts of the web content authoring platform for the Macintosh. This new release really bonds the products together, and opens the door for a closer connection in the future. BBEdit is an excellent commercial product from a company that upgrades its product and fixes bugs and cares for its customers.

They deserve your support.

What to expect

After climbing a quick (and fun!) learning curve, you can move up to the kind of editorial power previously available only on customized Unix content development systems.

Very little knowledge of Frontier and no scripting is required for the Glossary and for automatic enabling of email addresses and URLs. You can use the macro feature without learning how to script by copying text from sample files, or by downloading macro libraries thru the scripting.com server.

You can go very far, as some people already have, because the macro facility opens up all the power and connections of the Frontier environment, its object database, and scriptable apps.

Getting started

When the download is complete, after the archive is debinhexed and unstuffed, put the Frontier folder in your Apps folder, or where ever you have disk space.

Open the Frontier folder. Launch the UserLand Frontier app. The Frontier app is "fat" -- it contains 68K code and Native PowerPC code. Naturally, it runs much faster on PowerMacs.

Launch BBEdit. You'll see a new menu at the end of BBEdit's menu bar, called Scripts. This menu contains calls scripts that run in Frontier.

Page Preview

Create a new file in BBEdit, choose the New command from the File menu.

Add a little text to the file, something like:

<html>
I just downloaded Frontier and it looks interesting.
</html>

Save the file to disk.

Launch Netscape or Microsoft Internet Explorer. Back in BBEdit, choose Page Preview from the Scripts menu. The browser comes to the front and displays the text in the frontmost BBEdit window. This is a key feature -- with a single keystroke you can see what your HTML text looks like in a browser. I use this command a lot when I'm tweaking up a page. Quick back and forth -- that's totally essential.

Note: This is not a replacement for BBEdit's "View HTML File" command, or for Lindsey Davies's extensions. The Page Preview script flows the text thru Frontier's macro processor, the BBEdit command displays the literal text, without expanding macros or glossary entries.

Now, another key feature. Back in BBEdit, put double-quotes around Frontier, like this: "Frontier". Choose Page Preview from the Scripts menu. In your browser, notice that it's a link. That's the glossary. It's powerful! More info in the next section.

The Glossary

When you get to a place in your web travels that you want to refer to in your website, add it to the Frontier glossary by choosing the Add to Glossary command in the web browser's Scripts menu, which appears when Frontier is running. [This uses a standard technology called Menu Sharing.]

A dialog appears asking what you want to call the page. Enter a name and then click on OK. From that point on, when you put the name in double-quotes, a hotlink to that page will be generated.

Here are four examples: CNN, "Suck", Ignatius Reilly, Netscape.

"Suck" remains in quotes because it is not in my glossary. When the macro processor encounters a glossary name that's not in the database, it leaves the text alone.

Note that when you view this text in a web browser, after the macro processor has run, the double-quotes are gone, each of them is replaced with a hotlink.

Glossary names are limited to 127 characters.

You can edit the contents of the glossary by chosing the Open Glossary command from BBEdit's Scripts menu. Frontier comes to the front and the glossary table is opened. Edit the text of this table as you would any text on a Macintosh. When you're finished making changes, press Command-S to save to disk.

The glossary is an elegant approach to the problem that link validator software attempts to solve. By concentrating most or all of your links in the glossary, you can make a change in one place, rebuild all your pages, and all your links are cool. This gives you the power to correct URLs in one place.

A bit of philosophy about the glossary. After you use it for a bit, it becomes a basic resource for website stuff, like the Bookmarks menu in a web browser, with the difference that you have a collection of usable pointers for your web content, not just for your web browsing.

Automatic treatment of special Mac characters

The web has a special way of indicating characters that aren't basic alphabetic and numeric characters, and the Macintosh does it a different way. When these characters are transmitted thru the web and viewed in a browser, they end up looking wrong to people who aren't using Macintoshes.

The solution is easy, we pass every character thru a special filter that converts Macintosh special characters to the equivalent sequence in HTML. So you can continue to use the Mac, and have all your web pages look right.

For example, if you type in Señorita into BBEdit, the HTML produced by the macro processor will say Se&ntilde;orita.

Macros

Macros are simple, but they open the door for all kinds of automatic stuff. I use macros to generate tables of files you can download, and to automatically add the height and width parameters to <IMG> tags.

A macro is a bit of text enclosed in {curly braces}. When the text is processed, the text inside the braces is run thru Frontier's script interpreter. The text inside the curly braces is replaced with the value returned by the script. Therefore, macros can do anything a Frontier script can do.

Here's a simple example:

{(12 + 19) * 3} is replaced with 93.

Here are some other scripts and their values:

user.name = Dave Winer

clock.now () = 1/22/97; 2:29:55 PM

Frontier.version () = 4.2

Frontier.shipDate = 1/22/97; 12:05:13 PM

Another thing macros can be used for -- to include standard "colors" -- to wear your badges that tell people about your politics, or what tools you use. For example, you can wear the BBEdit badge by including {builtWithBBEdit ()} at the bottom your page. Here's what you'll get:

Built With BBEdit

Uploading with Fetch 3.0

We've added a command to the Scripts menu that uploads the current BBEdit file to a directory in my directory at www.hotwired.com.

If you want to use FTP to get your web files to the server, you can modify this script so it has the information for your server instead of mine.

The easiest way to edit the menu is to hold down the option key while selecting a command in the Scripts menu. Frontier comes to the front, opens an editing window for the Scripts menu and places the cursor on the command you selected.

Click on the Scripts button in the menu editor window. A new window opens containing the script. Change the values for domain and directory. Click on the Run button. A name and password dialog displays, then Fetch launches, and the frontmost file is uploaded to the server.

Close all the windows in Frontier, Command-S to save changes, and try running the command from the Scripts menu. It should upload as it did before. Now, any time you want to upload a file to this directory you can do it with a single command.

Uploading using the Mac file system

We've also included a command that copies the frontmost BBEdit window to a folder on a shared disk on my local network. Since I run a WebStar server on the same local net as my desktop machine, I can save the step of doing an FTP upload and can just use the Mac file system to copy the file to the server.

This script is even easier to modify. Open the script by choosing the Local Server command while holding down the option key. Click on the Script button. Change "Internal:Server Software:scripting.com:bbedit:" to a folder on your local net. Command-S to save, close all the windows in Frontier, bring BBEdit to the front. Now, whenever you want to save a file to your website just choose this command.

Note that both forms of uploading pass the text thru the macro processor before the upload happens.

Automatic enabling of URLs and mail addresses

This part is really easy to explain!

When a URL or a mail address appears in the text of your page, the macro processor automatically turns it into a hotlink. Here are some examples:

You can override it by preceding the special character with a backslash. In email addresses, the key character is the at-sign. In URLs its the pair of slashes.

That's about all I can think of! It's a pretty simple feature.

For Frontier experts

This section is for people who know how to use Frontier and how its object database works.

Your first question is likely to be Where do I store my macros? The answer is (of course!) anywhere you like. That doesn't help much.

There are two places we'll look first: user.html.macros and suites.html.data.standardMacros. All your macros run within a "with" statement that includes both of those tables.

In general, you should never put a macro in the standardMacros table because new releases of suites.html will clobber these scripts. We won't add many scripts to this table, only ones that I believe every author should have.

If you have a macro that you think you'll use in every website, store it in the user.html.macros table. Or store it there if you don't want to think too much.

If you have a website built with a complex set of scripts that interact with each other, start a new suite. This makes it easier to work on, and makes it possible for you to share your set of macros with other script writers.

General Notes

If a macro generates an error, the error message is inserted into the HTML text inside bold square brackets.

Any time the macro processor sees two consecutive carriage returns a <p> tag is inserted.

Any time you want to override the effect of a special character, precede it with a backslash. So if you don't want an email address to be hot, put a backslash before the at-sign.

To maintain backward compatibility with Clay Basket two special markups are supported. Any line that begins with three asterisks is boldfaced. Any line that contains only three dashes becomes a separator line. It's often easier to use the <b> and <hr> tags.

When you quit Frontier it will ask if you want to save changes. You should always choose to save changes.

I like to use Fetch to do my uploads because it works with all the FTP servers I have to work with. I don't have anything against Anarchie, or Peter N. Lewis, I just use Fetch because it works for me.

All the text handled by Frontier's macro processor flows thru a template. You can edit the template. First, bring Frontier to the front. Press Command-J. Enter user.html.templates.bbedit. It says <bodytext>. You can put stuff before that tag and after that tag. That stuff will appear on all pages rendered by Frontier.

Pointers

Here's a list of places containing more useful information:

  1. Bare Bones Software, makers of BBEdit.

  2. Website Building with Frontier, a tutorial on advanced website building with Frontier.

  3. CGI Scripting in Frontier, a tutorial on writing scripts that run behind WebSTAR and other popular Mac-based web servers.

© Copyright 1996-97 UserLand Software. This page was last built on Wed, Jan 22, 1997 at 2:29:56 PM with Frontier. Thanks for checking it out! Dave